﻿using AutoMapper;
using YAPACS.BusinessObjects.Exams;
using YAPACS.BusinessObjects.Managements.Exams;
using YAPACS.RisServer.Services.Dtos;

namespace YAPACS.RisServer.ObjectMapping;

public class RisServerAutoMapperProfile : Profile
{
    public RisServerAutoMapperProfile()
    {
        /* Create your AutoMapper object mappings here */
        CreateMap<Patient, PatientDto>()
            //身份证
            .ForMember(e => e.IdCardType, f => f.MapFrom(e => e.IdCardType.Oid))
            //医保卡类型
            .ForMember(e => e.MedicalInsuranceType, f => f.MapFrom(e => e.MedicalInsuranceType.Oid))
            //民族
            .ForMember(e => e.EthnicGroup, f => f.MapFrom(e => e.EthnicGroup.Oid))
            .ForMember(e => e.SexCH, f => f.MapFrom(e => e.Sex == PatientSex.Male ? "男" : (e.Sex == PatientSex.Female ? "女" : "其他")))
            .ForMember(e => e.ParentName, f => f.MapFrom(e => e.ParentName))
            .ForMember(e => e.BirthDate, f => f.MapFrom(e => e.BirthDate.Value.ToString("yyyy-MM-dd")))
            .ForMember(e => e.IdCardTypeName, f => f.MapFrom(e => e.IdCardType.Name));

        CreateMap<Exam, ExamDto>()
            //患者来自
            .ForMember(e => e.PatientFrom, f => f.MapFrom(e => e.PatientFrom.Oid))
            //患者类型
            .ForMember(e => e.PatientType, f => f.MapFrom(e => e.PatientType.Oid))
            //申请医生
            .ForMember(e => e.ApplyDoctor, f => f.MapFrom(e => e.ApplyDoctor.Oid))
            //申请科室
            .ForMember(e => e.ApplyDepartment, f => f.MapFrom(e => e.ApplyDepartment.Oid))
            ////检查方法
            //.ForMember(e => e.ExamMethods, f => f.MapFrom(e => e.ExamMethods.Select(g => new ExamMethodDto { Oid = g.Oid, Name = g.Name, Code = g.Code })))
            ////检查部位
            //.ForMember(e => e.ExamBodyParties, f => f.MapFrom(e => e.ExamBodyParties.Select(h => new ExamBodyPartyDto { Oid = h.Oid, Name = h.Name, Code = h.Code })))
            ////检查项目
            //.ForMember(e => e.ExamItems, f => f.MapFrom(e => e.ExamItems.Select(h => new ExamItemDto { Oid = h.Oid, Name = h.Name, Code = h.Code })))
            //.ForMember(e => e.PatientMatters, f => f.MapFrom(e => e.PatientMatters.Select(h => new PatientMatterDto { Oid = h.Oid, Content = h.Content, IsStrong = h.IsStrong })))
            ////患者特征
            //.ForMember(e => e.PatientFeatures, f => f.MapFrom(e => e.PatientFeatures.Select(h => new PatientFeatureDto { Oid = h.Oid, Code = h.Code, Name = h.Name })))
            //检查设备
            .ForMember(e => e.ExamDevice, f => f.MapFrom(e => e.ExamDevice.Oid))
            .ForMember(e => e.ExamDeviceName, f => f.MapFrom(e => e.ExamDevice.Name))
            .ForMember(e => e.ExamStationName, f => f.MapFrom(e => e.ExamDevice.Station.Name))
            .ForMember(e => e.ExamRoomName, f => f.MapFrom(e => e.ExamDevice.Station.Room.Name))
            .ForMember(e => e.UseDeviceCompoundName, f => f.MapFrom(e => e.ExamDevice.VisibleCompoundName))
            .ForMember(e => e.IsVideoDevice, f => f.MapFrom(e => e.ExamDevice.EnableGenerateStudyUID))
            //设备类型
            .ForMember(e => e.DeviceType, f => f.MapFrom(e => e.DeviceType.Oid))
            .ForMember(e => e.DeviceTypeText, f => f.MapFrom(e => e.DeviceType.Name))
            //预约计划
            .ForMember(e => e.AppointmentPlan, f => f.MapFrom(e => e.AppointmentPlan.Oid))
            .ForMember(e => e.ExamHelper, f => f.MapFrom(e => e.ExamHelper.Oid))
            .ForMember(e => e.ExamHelper2, f => f.MapFrom(e => e.ExamHelper2.Oid))
            .ForMember(e => e.ExamHelper3, f => f.MapFrom(e => e.ExamHelper3.Oid))
            .ForMember(e => e.ExamOperator, f => f.MapFrom(e => e.ExamHelper3.Oid))
            .ForMember(e => e.ExamCategory, f => f.MapFrom(e => e.ExamCategory.Oid))
            .ForMember(e => e.Profession, f => f.MapFrom(e => e.Profession.Oid))
            .ForMember(e => e.MaritalStatus, f => f.MapFrom(e => e.MaritalStatus.Oid))
            .ForMember(e => e.AppointmentName, f => f.MapFrom(e => e.AppointmentPlan != null && e.AppointmentPlan.Date.HasValue ? e.AppointmentPlan.Date.Value.ToString("yyyy年MM月dd日") + " , " + e.AppointmentPlan.TimeInterval.Name + " , " + e.AppointmentPlan.Device.CompoundName : null))
            .ForMember(e => e.AppointmentDate, f => f.MapFrom(e => e.AppointmentPlan != null ? e.AppointmentPlan.Date.Value.ToString("yyyy-MM-dd") : DateTime.Now.Date.ToString("yyyy-MM-dd")))
            .ForMember(e => e.AppointmentNumber, f => f.MapFrom(e => e.ExamAppointment.AppointmentNumber))
            .ForMember(e => e.ExpertGroup, f => f.MapFrom(e => e.ExpertGroup.Oid.ToString()))
            .ForMember(e => e.MaritalStatus, f => f.MapFrom(e => e.MaritalStatus.Oid));

        CreateMap<ExamMethod, ExamMethodDto>();
        CreateMap<ExamBodyParty, ExamBodyPartyDto>();
        CreateMap<ExamItem, ExamItemDto>();
        CreateMap<PatientFeature, PatientFeatureDto>();
        CreateMap<PatientMatter, PatientMatterDto>();

        _ = CreateMap<Report, ReportDto>()
            .ForMember(e => e.ReportImageQuality, f => f.MapFrom(e => e.ReportImageQuality.Oid))
            .ForMember(e => e.ReportImageQualityName, f => f.MapFrom(e => e.ReportImageQuality.Name))
            .ForMember(e => e.ExamMethods, f => f.MapFrom(e => e.ExamMethods.Select(f => f.Oid)))
            .ForMember(e => e.ExamItems, f => f.MapFrom(e => e.ExamItems.Select(f => f.Oid)))
            .ForMember(e => e.ExamBodyParties, f => f.MapFrom(e => e.ExamBodyParties.Select(f => f.Oid)))
            .ForMember(e => e.InitialWritingDoctor, f => f.MapFrom(e => e.InitialWritingDoctor.Name))
            .ForMember(e => e.InitialWritingTime, f => f.MapFrom(e => e.InitialWritingTime.HasValue ? e.InitialWritingTime.Value.ToString("yyyy/MM/dd HH:mm:ss") : null))
            .ForMember(e => e.ReportDoctor, f => f.MapFrom(e => e.ReportDoctor.Name))
            .ForMember(e => e.ReportTime, f => f.MapFrom(e => e.ReportTime.HasValue ? e.ReportTime.Value.ToString("yyyy/MM/dd HH:mm:ss") : null))
            .ForMember(e => e.AuditDoctor, f => f.MapFrom(e => e.AuditDoctor.Name))
            .ForMember(e => e.AuditTime, f => f.MapFrom(e => e.AuditTime.HasValue ? e.AuditTime.Value.ToString("yyyy/MM/dd HH:mm:ss") : null))
            .ForMember(e => e.ReviewDoctor, f => f.MapFrom(e => e.ReviewDoctor.Name))
            .ForMember(e => e.ReviewTime, f => f.MapFrom(e => e.ReviewTime.HasValue ? e.ReviewTime.Value.ToString("yyyy/MM/dd HH:mm:ss") : null));

        CreateMap<PatientDto, Patient>()
            .ForMember(e => e.Oid, f => f.MapFrom(e => e.Oid))
            .ForMember(e => e.Id, f => f.MapFrom(e => e.PatientId))
            .ForMember(e => e.Name, f => f.MapFrom(e => e.Name))
            .ForMember(e => e.OldName, f => f.MapFrom(e => e.OldName))
            .ForMember(e => e.ParentName, f => f.MapFrom(e => e.ParentName))
            .ForMember(e => e.NamePinYin, f => f.MapFrom(e => e.NamePinYin))
            .ForMember(e => e.Sex, f => f.MapFrom(e => e.Sex))
            .ForMember(e => e.BirthDate, f => f.MapFrom(e => new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(Convert.ToInt64(e.BirthDate)).ToLocalTime()))
            .ForMember(e => e.IdCardNumber, f => f.MapFrom(e => e.IdCardNumber))
            .ForMember(e => e.MedicalInsuranceNumber, f => f.MapFrom(e => e.MedicalInsuranceNumber))
            .ForMember(e => e.PhoneNumber, f => f.MapFrom(e => e.PhoneNumber))
            .ForMember(e => e.PhoneNumber2, f => f.MapFrom(e => e.PhoneNumber2))
            .ForMember(e => e.Address, f => f.MapFrom(e => e.Address));

        CreateMap<ExamDto, Exam>()
            .ForMember(e => e.Oid, f => f.MapFrom(e => e.Oid))
            .ForMember(e => e.AccessionNumber, f => f.MapFrom(e => e.AccessionNumber))
            .ForMember(e => e.Patient, f => f.MapFrom(e => e.Patient))
            .ForMember(e => e.AgeValue, f => f.MapFrom(e => e.AgeValue))
            .ForMember(e => e.AgeUnit, f => f.MapFrom(e => e.AgeUnit))
            .ForMember(e => e.Height, f => f.MapFrom(e => e.Height))
            .ForMember(e => e.Weight, f => f.MapFrom(e => e.Weight))
            .ForMember(e => e.BMI, f => f.MapFrom(e => e.BMI))
            .ForMember(e => e.PhysicalExamNumber, f => f.MapFrom(e => e.PhysicalExamNumber))
            .ForMember(e => e.OutPatientNumber, f => f.MapFrom(e => e.OutPatientNumber))
            .ForMember(e => e.InPatientNumber, f => f.MapFrom(e => e.InPatientNumber))
            .ForMember(e => e.InPatientArea, f => f.MapFrom(e => e.InPatientArea))
            .ForMember(e => e.WardNumber, f => f.MapFrom(e => e.WardNumber))
            .ForMember(e => e.BedNumber, f => f.MapFrom(e => e.BedNumber))
            .ForMember(e => e.ApplyTime, f => f.MapFrom(e => e.ApplyTime))
            .ForMember(e => e.ClinicalDiagnosis, f => f.MapFrom(e => e.ClinicalDiagnosis))
            .ForMember(e => e.MenstrualHistory, f => f.MapFrom(e => e.MenstrualHistory))
            .ForMember(e => e.LastMenstruationDate, f => f.MapFrom(e => e.LastMenstruationDate))
            .ForMember(e => e.GestationalWeek, f => f.MapFrom(e => e.GestationalWeek))
            .ForMember(e => e.ChildbirthDate, f => f.MapFrom(e => e.ChildbirthDate))
            .ForMember(e => e.IsPregnancy, f => f.MapFrom(e => e.IsPregnancy))
            .ForMember(e => e.Remark, f => f.MapFrom(e => e.Remark))
            .ForMember(e => e.IsEmergency, f => f.MapFrom(e => e.IsEmergency))
            .ForMember(e => e.AppointmentTime, f => f.MapFrom(e => e.AppointmentTime))
            .ForMember(e => e.IsSensitive, f => f.MapFrom(e => e.IsSensitive))
            .ForMember(e => e.IsCritical, f => f.MapFrom(e => e.IsCritical))
            .ForMember(e => e.IsAppointment, f => f.MapFrom(e => e.IsAppointment))
            .ForMember(e => e.AllergyHistory, f => f.MapFrom(e => e.AllergyHistory))
            .ForMember(e => e.ChiefComplaint, f => f.MapFrom(e => e.ChiefComplaint))
            .ForMember(e => e.MedicalHistory, f => f.MapFrom(e => e.MedicalHistory))
            .ForMember(e => e.MedicalRecordNumber, f => f.MapFrom(e => e.MedicalRecordNumber))
            .ForMember(e => e.InvoiceNumber, f => f.MapFrom(e => e.InvoiceNumber))
            .ForMember(e => e.BillNumber, f => f.MapFrom(e => e.BillNumber))
            .ForMember(e => e.ApplyNumber, f => f.MapFrom(e => e.ApplyNumber))
            .ForMember(e => e.MedicalCardNumber, f => f.MapFrom(e => e.MedicalCardNumber));

        CreateMap<ReportStyle, ReportStyleDto>();

        CreateMap<ExamRemark, ExamRemakDto>()
            .ForMember(e => e.LevelName, f => f.MapFrom(e => e.Level.Name))
            .ForMember(e => e.Level, f => f.MapFrom(e => e.Level.Oid))
            .ForMember(e => e.Content, f => f.MapFrom(e => e.Content))
            .ForMember(e => e.Exam, f => f.MapFrom(e => e.Exam.Oid))
            .ForMember(e => e.Oid, f => f.MapFrom(e => e.Oid));

        CreateMap<ExamApplyDto, ExamApplyItem>();

        CreateMap<Exam, Exam>()
            .ForMember(d => d.Id, ops => ops.Ignore())
            .ForMember(d => d.ExamAppointment, ops => ops.Ignore())
            .ForMember(d => d.ExamQueuing, ops => ops.Ignore())
            .ForMember(d => d.Report, ops => ops.Ignore())
            .ForMember(d => d.ExamMethods, ops => ops.Ignore())
            .ForMember(d => d.ExamBodyParties, ops => ops.Ignore())
            .ForMember(d => d.ExamItems, ops => ops.Ignore())
            .ForMember(d => d.PatientMatters, ops => ops.Ignore())
            .ForMember(d => d.PatientFeatures, ops => ops.Ignore())
            .ForMember(d => d.ExamFlags, ops => ops.Ignore())
            .ForMember(d => d.Studies, ops => ops.Ignore())
            .ForMember(d => d.Reports, ops => ops.Ignore())
            .ForMember(d => d.ExamForms, ops => ops.Ignore())
            .ForMember(d => d.ExamEvents, ops => ops.Ignore())
            .ForMember(d => d.ExamRemarks, ops => ops.Ignore())
            .ForMember(d => d.ExamApplyItems, ops => ops.Ignore())
            .ForMember(d => d.ExamAudits, ops => ops.Ignore())
            .ForMember(d => d.CreatorId, ops => ops.Ignore())
            .ForMember(d => d.CreationTime, ops => ops.Ignore())
            .ForMember(d => d.LastModifierId, ops => ops.Ignore())
            .ForMember(d => d.LastModificationTime, ops => ops.Ignore())
            .ForMember(d => d.IsObjectDeleted, ops => ops.Ignore())
            .ForMember(d => d.DeleterId, ops => ops.Ignore())
            .ForMember(d => d.DeletionTime, ops => ops.Ignore());

        CreateMap<ExamQueuing, WaitingPatientDto>()
            .ForMember(d => d.Number, ops => ops.MapFrom(e => e.CallNumber))
            .ForMember(d => d.Name, ops => ops.MapFrom(e => e.Exam.Patient.Name))
            .ForMember(d => d.Status, ops => ops.MapFrom(e => e.Status))
            .ForMember(d => d.IsEmergency, ops => ops.MapFrom(e => e.Exam.IsEmergency))
            .ForMember(d => d.IsSkip, ops => ops.MapFrom(e => e.IsSkip))
            .ForMember(d => d.IsReturnVisit, ops => ops.MapFrom(e => e.IsReturnVisit))
            .ForMember(d => d.IsReferral, ops => ops.MapFrom(e => e.IsReferral))
            .ForMember(d => d.IsPending, ops => ops.MapFrom(e => e.IsPending))
            .ForMember(d => d.IsGiveUp, ops => ops.MapFrom(e => e.IsGiveUp))
            .ForMember(d => d.Order, ops => ops.MapFrom(e => e.Order))
            .ForMember(d => d.AppointmentTime, ops => ops.MapFrom(e => e.Exam.AppointmentTime))
            .ForMember(d => d.CreationTime, ops => ops.MapFrom(e => e.CreationTime));


        CreateMap<Exam, ArchiveDto>()
            .ForMember(d => d.Oid, ops => ops.MapFrom(e => Guid.NewGuid()))
            .ForMember(d => d.ExamId, ops => ops.MapFrom(e => e.Oid.ToString()))
            .ForMember(d => d.StudyInstanceUid, ops => ops.MapFrom(e => string.Join(',', e.Studies.Select(e => e.StudyInstanceUid))))
            .ForMember(d => d.AgeUnit, ops => ops.MapFrom(e => e.AgeUnit == AgeUnit.Year ? "岁" : e.AgeUnit == AgeUnit.Month ? "月" : e.AgeUnit == AgeUnit.Day ? "天" : e.AgeUnit == AgeUnit.Hour ? "时" : ""))
            .ForMember(d => d.PatientFrom, ops => ops.MapFrom(e => e.PatientFrom.Name))
            .ForMember(d => d.PatientType, ops => ops.MapFrom(e => e.PatientType.Name))
            .ForMember(d => d.ApplyDoctor, ops => ops.MapFrom(e => e.ApplyDoctor.Name))
            .ForMember(d => d.ApplyDepartmentText, ops => ops.MapFrom(e => e.ApplyDepartment.Name))
            .ForMember(d => d.ApplyDepartment, ops => ops.MapFrom(e => e.ApplyDepartment.Oid.ToString()))
            .ForMember(d => d.ExamHelper, ops => ops.MapFrom(e => e.ExamHelper.Name))
            .ForMember(d => d.ExamHelper2, ops => ops.MapFrom(e => e.ExamHelper2.Name))
            .ForMember(d => d.ExamHelper3, ops => ops.MapFrom(e => e.ExamHelper3.Name))
            .ForMember(d => d.ExamOperator, ops => ops.MapFrom(e => e.ExamOperator.Name))
            //.ForMember(d => d.PatientMattersText, ops => ops.MapFrom(e => string.Join(',', e.PatientMatters.Select(e => e.Content))))
            .ForMember(d => d.ExamCategoryText, ops => ops.MapFrom(e => e.ExamCategory.Name))
            .ForMember(d => d.Profession, ops => ops.MapFrom(e => e.Profession.Name))
            .ForMember(d => d.MaritalStatus, ops => ops.MapFrom(e => e.MaritalStatus.Name))
            .ForMember(d => d.ExamRemarksText, ops => ops.MapFrom(e => string.Join(',', e.ExamRemarks.Select(e => e.Content))))
            .ForMember(d => d.ExamDepartment, ops => ops.MapFrom(e => e.ExamDepartment.Name))
            .ForMember(d => d.ExamDeviceText, ops => ops.MapFrom(e => e.ExamDevice.CompoundName))
            .ForMember(d => d.ExamDevice, ops => ops.MapFrom(e => e.ExamDevice.Oid.ToString()))
            .ForMember(d => d.DeviceTypeText, ops => ops.MapFrom(e => e.DeviceType.Name))
            .ForMember(d => d.DeviceType, ops => ops.MapFrom(e => e.DeviceType.Oid.ToString()))
            .ForMember(d => d.DepartmentText, ops => ops.MapFrom(e => e.Department.Name))
            .ForMember(d => d.Department, ops => ops.MapFrom(e => e.Department.Oid.ToString()))
            //.ForMember(d => d.InterfaceService, ops => ops.MapFrom(e => e.InterfaceService.Name))
            .ForMember(d => d.ExpertGroup, ops => ops.MapFrom(e => e.ExpertGroup.Name))
            //.ForMember(d => d.InitialWritingCandidate, ops => ops.MapFrom(e => e.InitialWritingCandidate.Name))
            //.ForMember(d => d.ReportCandidate, ops => ops.MapFrom(e => e.ReportCandidate.Name))
            //.ForMember(d => d.AuditionCandidate, ops => ops.MapFrom(e => e.AuditionCandidate.Name))
            //.ForMember(d => d.StoreService, ops => ops.MapFrom(e => e.StoreService.Name))
            .ForMember(d => d.ExamStationName, ops => ops.MapFrom(e => e.ExamDevice.Station.Name))
            .ForMember(d => d.ExamRoomName, ops => ops.MapFrom(e => e.ExamDevice.Station.Room.Name))
            .ForMember(d => d.PatientId, ops => ops.MapFrom(e => e.Patient.PatientId))
            .ForMember(d => d.PatientName, ops => ops.MapFrom(e => e.Patient.Name))
            .ForMember(d => d.OldName, ops => ops.MapFrom(e => e.Patient.OldName))
            .ForMember(d => d.ParentName, ops => ops.MapFrom(e => e.Patient.ParentName))
            .ForMember(d => d.NamePinYin, ops => ops.MapFrom(e => e.Patient.NamePinYin))
            .ForMember(d => d.Sex, ops => ops.MapFrom(e => e.Patient.Sex == PatientSex.Female ? "Female" : e.Patient.Sex == PatientSex.Male ? "Male" : "Other"))
            //.ForMember(d => d.Sex, ops => ops.MapFrom(e => e.Patient.Sex))
            .ForMember(d => d.BirthDate, ops => ops.MapFrom(e => e.Patient.BirthDate))
            .ForMember(d => d.IdCardType, ops => ops.MapFrom(e => e.Patient.IdCardType.Name))
            .ForMember(d => d.IdCardNumber, ops => ops.MapFrom(e => e.Patient.IdCardNumber))
            .ForMember(d => d.MedicalInsuranceType, ops => ops.MapFrom(e => e.Patient.MedicalInsuranceType.Name))
            .ForMember(d => d.MedicalInsuranceNumber, ops => ops.MapFrom(e => e.Patient.MedicalInsuranceNumber))
            .ForMember(d => d.ElectronicHealthCode, ops => ops.MapFrom(e => e.Patient.ElectronicHealthCode))
            .ForMember(d => d.PhoneNumber, ops => ops.MapFrom(e => e.Patient.PhoneNumber))
            .ForMember(d => d.PhoneNumber2, ops => ops.MapFrom(e => e.Patient.PhoneNumber2))
            .ForMember(d => d.Address, ops => ops.MapFrom(e => e.Patient.Address))
            .ForMember(d => d.EthnicGroup, ops => ops.MapFrom(e => e.Patient.EthnicGroup.Name))
            .ForMember(d => d.ReportId, ops => ops.MapFrom(e => e.Report.Oid.ToString()))
            .ForMember(d => d.ExamResult, ops => ops.MapFrom(e => e.Report.ExamResult == ExamResult.Positive ? "阳性" : "阴性"))
            .ForMember(d => d.ImageSeeing, ops => ops.MapFrom(e => e.Report.ImageSeeing))
            .ForMember(d => d.ImageDiagnosis, ops => ops.MapFrom(e => e.Report.ImageDiagnosis))
            .ForMember(d => d.ImageOpinion, ops => ops.MapFrom(e => e.Report.ImageOpinion))
            .ForMember(d => d.ReportExtending, ops => ops.MapFrom(e => e.Report.ReportExtending))
            .ForMember(d => d.ReportExtendingSchema, ops => ops.MapFrom(e => e.Report.ReportExtendingSchema))
            //.ForMember(d => d.ReportStyle, ops => ops.MapFrom(e => e.Report.ReportStyle.DisplayName))
            .ForMember(d => d.IsFollowup, ops => ops.MapFrom(e => e.Report.IsFollowup))
            .ForMember(d => d.FollowupResult, ops => ops.MapFrom(e => e.Report.FollowupResult))
            .ForMember(d => d.FollowupRecord, ops => ops.MapFrom(e => e.Report.FollowupRecord))
            .ForMember(d => d.FollowupRecordSchema, ops => ops.MapFrom(e => e.Report.FollowupRecordSchema))
            .ForMember(d => d.RevisitTime, ops => ops.MapFrom(e => e.Report.RevisitTime))
            .ForMember(d => d.ActualRevisitTime, ops => ops.MapFrom(e => e.Report.ActualRevisitTime))
            .ForMember(d => d.RevisitRemark, ops => ops.MapFrom(e => e.Report.RevisitRemark))
            .ForMember(d => d.RevisitRecord, ops => ops.MapFrom(e => e.Report.RevisitRecord))
            .ForMember(d => d.RevisitRecordSchema, ops => ops.MapFrom(e => e.Report.RevisitRecordSchema))
            .ForMember(d => d.InitialWritingDoctor, ops => ops.MapFrom(e => e.Report.InitialWritingDoctor.Name))
            .ForMember(d => d.InitialWritingInstitution, ops => ops.MapFrom(e => e.Report.InitialWritingInstitution.Name))
            .ForMember(d => d.InitialWritingStartTime, ops => ops.MapFrom(e => e.Report.InitialWritingStartTime))
            .ForMember(d => d.InitialWritingTime, ops => ops.MapFrom(e => e.Report.InitialWritingTime))
            .ForMember(d => d.ReportDoctor, ops => ops.MapFrom(e => e.Report.ReportDoctor.Name))
            .ForMember(d => d.ReportInstitution, ops => ops.MapFrom(e => e.Report.ReportInstitution.Name))
            .ForMember(d => d.ReportStartTime, ops => ops.MapFrom(e => e.Report.ReportStartTime))
            .ForMember(d => d.ReportTime, ops => ops.MapFrom(e => e.Report.ReportTime))
            .ForMember(d => d.AuditDoctor, ops => ops.MapFrom(e => e.Report.AuditDoctor.Name))
            .ForMember(d => d.AuditInstitution, ops => ops.MapFrom(e => e.Report.AuditInstitution.Name))
            .ForMember(d => d.AuditStartTime, ops => ops.MapFrom(e => e.Report.AuditStartTime))
            .ForMember(d => d.AuditTime, ops => ops.MapFrom(e => e.Report.AuditTime))
            .ForMember(d => d.ReviewDoctor, ops => ops.MapFrom(e => e.Report.ReviewDoctor.Name))
            .ForMember(d => d.ReviewInstitution, ops => ops.MapFrom(e => e.Report.ReviewInstitution.Name))
            .ForMember(d => d.ReviewStartTime, ops => ops.MapFrom(e => e.Report.ReviewStartTime))
            .ForMember(d => d.ReviewTime, ops => ops.MapFrom(e => e.Report.ReviewTime))
            .ForMember(d => d.ReportCompletedTime, ops => ops.MapFrom(e => e.Report.CompletedTime))
            .ForMember(d => d.PrintingTimes, ops => ops.MapFrom(e => e.Report.PrintingTimes))
            .ForMember(d => d.LastPrintingTime, ops => ops.MapFrom(e => e.Report.LastPrintingTime))
            .ForMember(d => d.ReportPanicValue, ops => ops.MapFrom(e => e.Report.ReportPanicValue != null))
            .ForMember(d => d.ReportImageQuality, ops => ops.MapFrom(e => e.Report.ReportImageQuality.Name))
            .ForMember(d => d.ICD10s, ops => ops.MapFrom(e => string.Join(',', e.Report.ICD10s.Select(e => e.Name))))
            .ForMember(d => d.ACRs, ops => ops.MapFrom(e => string.Join(',', e.Report.ACRs.Select(e => e.Name))))
            .ForMember(d => d.ReportUrl, ops => ops.MapFrom(e => "/"+e.Report.ReportFile))
            .ForMember(d => d.ReportImagesPath, ops => ops.MapFrom(e => e.Report.ReportImagesPath))
            .ForMember(d => d.ReportVideosPath, ops => ops.MapFrom(e => e.Report.ReportVideosPath))
            .ForMember(d => d.ExamMethods, ops => ops.MapFrom(e => string.Join(',', e.ExamMethods.Select(e => e.Oid))))
            .ForMember(d => d.ExamBodyParties, ops => ops.MapFrom(e => string.Join(',', e.ExamBodyParties.Select(e => e.Oid))))
            .ForMember(d => d.ExamItems, ops => ops.MapFrom(e => string.Join(',', e.ExamItems.Select(e => e.Oid))))
            //.ForMember(d => d.PatientMatters, ops => ops.MapFrom(e => string.Join(',', e.PatientMatters.Select(e => e.Oid))))
            .ForMember(d => d.PatientFeatures, ops => ops.MapFrom(e => string.Join(',', e.PatientFeatures.Select(e => e.Oid))))
            .ForMember(d => d.ExamMethods, ops => ops.MapFrom(e => string.Join(',', e.ExamMethods.Select(e => e.Oid))))
            .ForMember(d => d.ExamMethods, ops => ops.MapFrom(e => string.Join(',', e.ExamMethods.Select(e => e.Oid))))
            .ForMember(d => d.ExamCategory, ops => ops.MapFrom(e => e.ExamCategory.Oid.ToString()))
            .ForMember(d => d.ReportUrlBase, ops => ops.MapFrom(e => e.StoreService.HttpServer));
    }
}
